﻿//--------------------------------------------------------------------------
// 
//  Copyright (c) Chili Software.  All rights reserved. 
// 
//  File: OEParameter.cs
//
//  Description: Parameter for the ObjectExpression.
// 
//--------------------------------------------------------------------------

using System;

namespace Chili.Opf3.Query.OPathParser
{
	/// <summary>
	/// Represents a parameter in the OPath statement. 
	/// </summary>
	/// <remarks>
	/// Parameters in a OPath statement are converted to this class when OPath is compiled.
	/// This parameter varies from the <see cref="OEInlineParameter">InlineParameter</see> since the
	/// parameter is represented as a tag ({0}, {1}, ...) in the OPath expression.
	/// </remarks>
	[Serializable]
	public sealed class OEParameter : OEItem
	{
		private object _value;
		private Type _type;

		/// <summary>
		/// Creates a new instance of the <see cref="OEParameter">OEParameter Class</see>.
		/// </summary>
		/// <param name="value">The value of the parameter.</param>
		/// <param name="type">The type of the parameter. This type is required if the value is null.</param>
		internal OEParameter(object value, Type type)
		{
			_value = value;
			_type = type;
		}

		/// <summary>
		/// Returns the value of the parameter. The value is stored in the parameter collection of the
		/// command that is executed on the storage.
		/// </summary>
		/// <value>The value of the parameter.</value>
		public object Value
		{
			get { return _value; }
		}

		/// <summary>
		/// Returns the type of the value.
		/// </summary>
		public Type ValueType
		{
			get { return _type; }
		}
	}
}
